package com.itheima.controller;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author ：hg
 * @date ：Created in 2021/12/23 13:30
 * @description：
 */
@RestController
@RequestMapping("/hello")
public class HelloController {

    @RequestMapping("/add")
    @PreAuthorize("hasAuthority('add')") //表示用户必须拥有add权限才能调用当前方法
    public String add() {
        System.out.println("add...............");
        return "success";
    }

    @RequestMapping("/del")
    @PreAuthorize("hasRole('ROLE_ADMIN')") //表示用户必须拥有add权限才能调用当前方法
    public String del() {
        System.out.println("del...............");
        return "success";
    }

}
